#ifndef NMC_ROOMVIEW_HPP
#define NMC_ROOMVIEW_HPP

#include "guichan.hpp"
#include "tilemap.hpp"

#include <set>
#include <map>

namespace nmc
{
    class RoomView: 
        public gcn::Widget, 
        public gcn::MouseListener
    {
    public:
        enum RoomViewMode
        {
            LOCKED,
            SELECT_TILE,
            SELECT_TILES,
            SELECT_AREA,
            MOVE_AREA
        };

        RoomView(TileMap* tileMap);
        ~RoomView();
        void draw(gcn::Graphics* graphics);
        void drawTileHoverMarker(gcn::Graphics* graphics);
        void drawSelectedAreaMarker(gcn::Graphics* graphics);
        void logic();
        void mouseMoved(gcn::MouseEvent& mouseEvent);
        void mouseDragged(gcn::MouseEvent& mouseEvent);
        void mousePressed(gcn::MouseEvent& mouseEvent);
        void mouseReleased(gcn::MouseEvent& mouseEvent);
        void mouseEntered(gcn::MouseEvent& mouseEvent);
        void mouseExited(gcn::MouseEvent& mouseEvent);
        void setMode(RoomViewMode mode);
        unsigned int getMode();
        gcn::Rectangle getSelectedTile();
        std::set<std::pair<int, int> > RoomView::getSelectedTiles();
        gcn::Rectangle getSelectedArea();
        bool isAreaSelected();
        void selectAll();
        void selectNone();

    protected:
        TileMap* mTileMap;
        gcn::Rectangle mSelectedArea;
        bool mTileSelected;
        bool mAreaSelected;
        int mMouseX;
        int mMouseY;
        int mMousePressX;
        int mMousePressY;
        int mFrameCounter;
        RoomViewMode mMode;
        std::set<std::pair<int, int> > mSelectedTiles;
    };
}
#endif